<template>
  <div class="container">
    <el-dialog
      title="题目预览"
      :visible="showDialog"
      @close="close"
      width="900px"
    >
      <el-row style="margin-bottom: 15px">
        <el-col style="width: 25%"
          >【题型】:{{
            JumpList.questionType === '1'
              ? '单选'
              : JumpList.questionType === '2'
              ? '多选'
              : '简答'
          }}</el-col
        >
        <el-col style="width: 25%">【编号】:{{ JumpList.id }}</el-col>
        <el-col style="width: 25%"
          >【难度】:{{
            JumpList.difficulty === '1'
              ? '简单'
              : JumpList.difficulty === '2'
              ? '一般'
              : '困难'
          }}</el-col
        >
        <el-col style="width: 25%">【标签】:{{ JumpList.tags }}</el-col>
      </el-row>
      <el-row style="margin-bottom: 15px">
        <el-col style="width: 25%">【学科】：{{ JumpList.subjectName }}</el-col>
        <el-col style="width: 25%"
          >【目录】：{{ JumpList.directoryName }}</el-col
        >
        <el-col style="width: 25%">【方向】：{{ JumpList.direction }}</el-col>
      </el-row>
      <hr />
      <!-- 单选多选简答 -->
      <el-row>
        【题干】：

        <p v-html="JumpList.question" style="color: blue"></p>
        <p>
          <span v-if="JumpList.questionType === '1'"
            >单选题 选项：（以下选中的选项为正确答案）</span
          >
          <span v-else-if="JumpList.questionType === '2'"
            >多选题 选项：（以下选中的选项为正确答案）</span
          >
          <span v-else-if="JumpList.questionType === '3'"
            ></span
          >
        </p>
        <!-- 单选 -->
        <div v-if="JumpList.questionType === '1'">
          <el-row>
            <el-radio-group v-model="radio">
              <el-radio
                style="display: block; padding: 8px 0px"
                v-for="item in options"
                :key="item.id"
                :label="item.isRight"
                disabled
                >{{ item.title }}</el-radio
              >
            </el-radio-group>
          </el-row>
        </div>
        <!-- 多选 -->
        <div v-if="JumpList.questionType === '2'">
          <el-row>
            <el-checkbox-group v-model="checkList">
              <el-checkbox
                 style="display: block; padding: 8px 0px"
                v-for="item in options"
                :key="item.id"
                :label="item.isRight"
                :value="item.isRight"
                disabled
                >{{ item.title }}</el-checkbox
              >
            </el-checkbox-group>
          </el-row>
        </div>

      </el-row>

      <hr />
      <el-row>
        【参考答案】：
        <el-button type="danger" size="mini" @click="showVideo = true"
          >视频答案预览</el-button
        >
        <div class="video" v-if="showVideo">
          <video :src="JumpList.videoURL" style="width: 100%; height: 100%" controls="controls"></video>
        </div>
      </el-row>
      <hr />
      <el-row>
        【答案解析】：<span
          v-html="JumpList.answer"
          style="display: inline-block"
        ></span>
      </el-row>
      <hr />
      <el-row>【题目备注】：{{ JumpList.remarks }}</el-row>
      <el-row type="flex" style="text-align: end; margin-top: 20px">
        <el-col>
          <el-button type="primary" size="mini" @click="close">关闭</el-button>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import { detail } from '@/api/hmmm/questions'
export default {
  data () {
    return {
      JumpList: [],
      options: [],
      radio: 1,
      checkList: [1],
      showVideo: false
    }
  },
  props: {
    showDialog: {
      type: Boolean,
      default: false
    }
  },
  created () {},
  methods: {
    // 关闭
    close () {
      // 通知父组件 我关闭了
      this.$emit('update:showDialog', false)
      this.showVideo = false
    },
    async detail (id) {
      const { data } = await detail({ id })
      console.log(data)
      this.JumpList = data
      this.options = data.options
    }
  }
}
</script>

<style scoped>
.video {
  width: 400px;
  height: 300px;
}
</style>
